using UnityEngine;
using System.Collections;

public class MHoverButton : MButton 
{
    protected bool bHover = true;

	// Use this for initialization
	public void Start () 
    {
        base.Start();
	}
	
	// Update is called once per frame
    public virtual void Update() 
    {
        if (bHover == true)
        {
            gameObject.renderer.material.mainTexture = view;
        }
        else
        {
            gameObject.renderer.material.mainTexture = view2;
        }
    }
	
	public virtual void OnEvent(Touch t)
	{
		touchPhase = t.phase;
		if( t.phase == TouchPhase.Began )
		{
			OnDown(t);
		}
		else if( t.phase == TouchPhase.Ended )
		{
			if( OnUp(t) == 1 )
			{
				OnMClick();
			}
		}
	}

	public virtual void OnMClick()
	{
		bHover = !bHover;
		MUIManager.Instance().Event(Id, this);
	}

	public bool IsDown
	{
		set { this.bHover = value; }
		get { return this.bHover; }
	}

}
